﻿#ifndef DAMETHODEDITORGRAPHICSVIEW_H
#define DAMETHODEDITORGRAPHICSVIEW_H
#include <QtCore/qglobal.h>
#include "DANodeGraphicsView.h"
#include "DAProject.h"
#include "DADataWorkFlow.h"
#include "DAWorkFlowGraphicsScene.h"
#include <QPointer>
#include "DAAbstractNodeWidget.h"
class GProject;

/**
 * @brief 用于节点显示的GraphicsView
 */
class DAWorkFlowGraphicsView : public DANodeGraphicsView
{
    Q_OBJECT
public:
    DAWorkFlowGraphicsView(QWidget *parent = 0);
    DAWorkFlowGraphicsView(QGraphicsScene *scene, QWidget *parent = 0);
    void setProject(DAProject *project);
    void setNodeFactory(DADataWorkFlow *factory);

signals:

    /**
     * @brief 选中了某个节点的设置窗口
     * @param w
     */
    void selectNodeItemChanged(DAAbstractNodeGraphicsItem *i);

protected:
    void dragEnterEvent(QDragEnterEvent *e) Q_DECL_OVERRIDE;
    void dragMoveEvent(QDragMoveEvent *e) Q_DECL_OVERRIDE;
    void dropEvent(QDropEvent *e) Q_DECL_OVERRIDE;
    void keyPressEvent(QKeyEvent *keyEvent) Q_DECL_OVERRIDE;
private slots:

    void onSceneSelectionChanged();
    //删除按键按下操作
    void onDeletePressed();
signals:

    /**
     * @brief 节点删除
     * @param item 节点
     */
    void nodeItemDeleted(const QList<QGraphicsItem *> &items);

private:
    QPointer<DAProject> m_project;
    QPointer<DADataWorkFlow> m_workflow;
};

#endif // GNODEGRAPHICSVIEW_H
